package com.wyh.apitest.source

import org.apache.flink.streaming.api.scala._

/**
  *
  * 模拟采集物联网的数据
  */

//定义样例类
case class SensorReading(id:String,timestamp:Long,temperature:Double)

object SourceTest {
  def main(args: Array[String]): Unit = {
    val streamEnv = StreamExecutionEnvironment.getExecutionEnvironment

    //从集合中读取数据
    val dataList = List(
      SensorReading("sensor_1", 1547718199, 35.8),
      SensorReading("sensor_6", 1547718201, 15.4),
      SensorReading("sensor_7", 1547718202, 6.7),
      SensorReading("sensor_10", 1547718205, 38.1)
    )
    val stream1 = streamEnv.fromCollection(dataList)
    stream1.print()
    val stream2: DataStream[Any] = streamEnv.fromElements(1.0,35,"hello")
    stream2.print()


    streamEnv.execute("Source Test")
  }

}